﻿@namespace MudBlazor
@inherits MudComponentBase
@typeparam T

<TemplateColumn T="T" Tag="@("hierarchy-column")" Sortable="false" Resizable="false" ShowColumnOptions="false" HeaderStyle="width:0%"
    Filterable="false" IsEditable="false">
    <CellTemplate>
         <MudIconButton 
            Class="ma-n3 pa-1"
            Icon="@(context.OpenHierarchies.Contains(context.Item) ?  OpenIcon : ClosedIcon)" 
            OnClick="context.Actions.ToggleHierarchyVisibilityForItemAsync"
            Size="@IconSize"
            Disabled="ButtonDisabledFunc.Invoke(context.Item)"/>
    </CellTemplate>
</TemplateColumn>

@code {
    [Parameter] public string ClosedIcon { get; set; } = Icons.Material.Filled.ChevronRight;
    [Parameter] public string OpenIcon { get; set; } = Icons.Material.Filled.ExpandMore;
    [Parameter] public Size IconSize { get; set; } = Size.Medium;
    [Parameter] public Func<T, bool> ButtonDisabledFunc { get; set; } = x => false;
}